package com.boyunv.strategy.example03;
/*
 *@description
 *  上下文类,持有策略接口,决定执行哪一个具体的策略类
 *@author boyunv
 *@create 2023/8/15 7:34
 *@version 1.0
 */

import com.boyunv.strategy.example02.Receipt;

public class ReceiptStrategyContext {
    private ReceiptHandlerStrategy receiptHandlerStrategy;
    
    public void setReceiptHandlerStrategy(ReceiptHandlerStrategy receiptHandlerStrategy) {
        this.receiptHandlerStrategy = receiptHandlerStrategy;
    }
    //调用策略类中的方法
    public void handleReceipt(Receipt receipt){
        if(receipt!=null){
            receiptHandlerStrategy.handleReceipt(receipt);
        }
    }
}
